// pages/account/withdrawals_list.js
var app = getApp();
var server = require("../../../utils/server.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: null,
    page: 1,
    count: 0,
    pagestatus: false,
    limit: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    server.postJSON("/User/transferAward_list", { userid: app.globalData.userInfo.user_id, page: that.data.page }, function (e) {
      console.log(e)
      if (e.data.code == 1) {
        that.setData({
          count: e.data.count,
          limit: e.data.limit,
          list: e.data.data,
          pagestatus: true,
        })
      }
    })
  },

  listpage: function () {
    var that = this;
    server.postJSON("/User/transferAward_list", { userid: app.globalData.userInfo.user_id, page: that.data.page }, function (e) {
      console.log(e)
      if (e.data.code == 1) {
        var list = that.data.list;
        for (var i = 0; i < e.data.data.length; i++) {
          list.push(e.data.data[i])
        }
        // list = Object.assign(list,res.data.log);
        that.setData({
          list: list,
          pagestatus: true,
        })
        console.log(list)
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if (!this.data.pagestatus) {
      return;
    }
    var page = this.data.page;
    var count = this.data.count;
    var limit = this.data.limit;
    var limitpage = Math.ceil(count / limit);
    if (page == limitpage) {
      wx.showLoading({
        title: '数据加载完毕',
      })
      setTimeout(function () {
        wx.hideLoading();
      }, 2000)
      return;
    }
    this.setData({
      pagestatus: false,
    })
    page++;
    this.setData({
      page: page,
    })
    this.listpage();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})